package com.xiyoukt.springboot.service;

import com.xiyoukt.springboot.constant.ResultEnum;
import com.xiyoukt.springboot.entity.Test;
import com.xiyoukt.springboot.exception.BusinessException;
import org.springframework.stereotype.Service;

@Service
public class TestService {

    public Test getTest(){
        // 从数据库查询数据
        Test test = new Test();
        test.setState(1);

        if(test.getState() == 0){
            throw new BusinessException(ResultEnum.CANNOT_OPEATION);
        }else if(test.getState() == 1){
            throw new BusinessException(ResultEnum.CANNOT_OPEATION);
        }else if(test.getState() == 2){
            throw new BusinessException(ResultEnum.HAS_DELETE);
        }

        return test;
    }

}
